﻿@model IEnumerable<StockPredictor.Models.PortfolioRecordModel>

@{
    ViewBag.Title = "My Portfolio";
}
<p>
    <i>Information last updated: @(ViewBag.CurrentTime)</i>
</p>
<p>
    @Html.ActionLink("Add to My Portfolio", "Create")
</p>

    @foreach (var item in Model)
    {
        var stockSymbol = @Html.DisplayFor(modelItem => item.StockSymbol);
        
        <h2>Portfolio Information for @Html.DisplayFor(modelItem => item.StockName)</h2>
        <table class="portfolio-table">
            <tr>
                <th>
                    Stock Symbol:
                </th>
                <td>
                    @Html.DisplayFor(modelItem => item.StockSymbol)
                </td>
                <th>
                    Shares I Own:
                </th>
                <td>
                    @Html.DisplayFor(modelItem => item.Shares)
                </td>
                <td>
                    @Html.ActionLink("Edit","Edit", new {id = item.PortfolioId })
                    @Html.ActionLink("Delete", "Delete", new { id = item.PortfolioId })
                </td>
        </table>
        <h3>Current Performance</h3>
        <table class="portfolio-table">
            @{
        var currentStock = StockPredictor.Controllers.MyPortfolioController.GetCurrentStockInfo(item.StockSymbol, User.Identity.Name);   
            }
            <tr>
                <th>
                    Current Change:
                </th>
                <td>
                    @Html.DisplayFor(stockItem => currentStock.Change)
                </td>
            </tr>
            <tr>
                <th>
                    Latest Open:
                </th>
                <td>
                    @Html.DisplayFor(stockItem => currentStock.Open)
                </td>
            </tr>
            <tr>
                <th>
                    Previous Close:
                </th>
                <td>
                    @Html.DisplayFor(stockItem => currentStock.PreviousClose)
                </td>
            </tr>
            <tr>
                <th>
                    Bid:
                </th>
                <td>
                   @Html.DisplayFor(stockItem => currentStock.Bid)
                </td>
            </tr>
            <tr>
                <th>
                    Ask:
                </th>
                <td>
                    @Html.DisplayFor(stockItem => currentStock.Ask)
                </td>
            </tr>
            <tr>
                <th>
                    Volume:
                </th>
                <td>
                    @Html.DisplayFor(stockItem => currentStock.Volume)
                </td>
            </tr>
            <tr>
                <th>
                    EPS:
                </th>
                <td>
                    @Html.DisplayFor(stockItem => currentStock.EPS)
                </td>
            </tr>
        </table>
        <h3>Historical Performance</h3>
        <div id="@(stockSymbol)chart" style="min-width:500px"></div>
        <script>chartHistoricalData('MyPortfolio', '@(stockSymbol)', 'Multiple');</script>
    }

